﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Lxzhu.OpenGL
{    
    /// <summary>
    /// 只接受位于0到1之间的Float
    /// </summary>
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public struct ClampFloat
    {
        private float mData;
        public ClampFloat(float v)
        {
            mData = 0;
            this.Value = v;
        }
        public float Value
        {
            get
            {
                return this.mData;
            }
            set
            {
                if (value >= 0.0f && value <= 1.0f)
                    mData = value;
                else throw new ArgumentOutOfRangeException("value", "This data must between [0.0,1.0]");
            }
        }
    }
    [Serializable]
    [StructLayout(LayoutKind.Sequential)]
    public struct ClampDouble
    {
        private double mData;
        public ClampDouble(double v)
        {
            mData = 0;
            this.Value = v;
        }
        public double Value
        {
            get
            {
                return this.mData;
            }
            set
            {
                if (value >= 0.0d && value <= 1.0d)
                    mData = value;
                else throw new ArgumentOutOfRangeException("value", "This data must between [0.0,1.0]");
            }
        }
    }
}
